home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / vsllib / std.vsl < prev    next >
Encoding:
Text File  |  1995-05-01  |  5.7 KB  |  224 lines

  1. // $Id: std.vsl,v 1.1.1.1 1995/05/01 15:48:44 zeller Exp $
  2. // VSL Standard Library
  3.  
  4. // Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
  6. // 
  7. // This file is part of the NORA Library.
  8. // 
  9. // The NORA Library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // The NORA Library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU Library General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with the NORA Library -- see the file COPYING.LIB.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 675 Mass Ave, Cambridge, MA 02139, USA.
  23. // 
  24. // NORA is an experimental inference-based software development
  25. // environment. Contact nora@ips.cs.tu-bs.de for details.
  26.  
  27. #include <builtin.vsl>
  28.  
  29. // Version
  30. std_version() = "$RCSfile: std.vsl,v $ $Revision: 1.1.1.1 $";
  31.  
  32. // Constants
  33. rulethickness() = 1;
  34. whitethickness() = 2;
  35. indentamount() = hspace("  ");
  36. true  = 1;
  37. false = 0;
  38.  
  39. // Some Macros...
  40.  
  41. // Maximum, minimum
  42. max(a) = a;
  43. max(a, b, ...) = if a > b then max(a, ...) else max(b, ...) fi;
  44. min(a) = a;
  45. min(a, b, ...) = if a < b then min(a, ...) else min(b, ...) fi;
  46.  
  47. // Fillers
  48. hfill() = vfix(fill());
  49. vfill() = hfix(fill());
  50.  
  51. // Neutral elements
  52. hnull() = vfill();    // neutral element for &
  53. vnull() = hfill();    // neutral element for |
  54.  
  55. // Black and white lines
  56. hrule(thickness) = rule() & vspace(thickness);
  57. vrule(thickness) = rule() | hspace(thickness);
  58. hwhite(thickness) = fill() & vspace(thickness);
  59. vwhite(thickness) = fill() | hspace(thickness);
  60.  
  61. hrule() = hrule(rulethickness());
  62. vrule() = vrule(rulethickness());
  63. hwhite() = hwhite(whitethickness());
  64. vwhite() = vwhite(whitethickness());
  65.  
  66. // Fixers
  67. fix(a)  = hfix(vfix(a));
  68. space(a) = hspace(a) + vspace(a);
  69.  
  70. // Box
  71. box(x) = x;
  72. box(x,y) = hspace(x) + vspace(y);
  73.  
  74. // Alignments
  75. halign(...) = (&)(...);
  76. valign(...) = (|)(...);
  77. talign(...) = (~)(...);
  78.  
  79. // Reverse alignments
  80. hralign() = hnull();
  81. hralign(head) = head;
  82. hralign(head, ...) = hralign(...) & head;
  83. tralign() = hnull();
  84. tralign(head) = head;
  85. tralign(head, ...) = tralign(...) ~ head;
  86. vralign() = vnull();
  87. vralign(head) = head;
  88. vralign(head, ...) = vralign(...) | head;
  89.  
  90. // Lists
  91. hlist(_) = hnull();
  92. hlist(_, head) = head;
  93. hlist(sep, head, ...) = head & sep & hlist(sep, ...);
  94.  
  95. tlist(_) = hnull();
  96. tlist(_, head) = head;
  97. tlist(sep, head, ...) = head ~ sep ~ tlist(sep, ...);
  98.  
  99. vlist(_) = vnull();
  100. vlist(_, head) = head;
  101. vlist(sep, head, ...) = head | sep | vlist(sep, ...);
  102.  
  103. hvlist(_) = vnull();
  104. hvlist(sep, head) = head & sep;
  105. hvlist(sep, head, ...) = head & sep | hvlist(sep, ...);
  106.  
  107. tvlist(_) = vnull();
  108. tvlist(sep, head) = head ~ sep;
  109. tvlist(sep, head, ...) = head ~ sep | tvlist(sep, ...);
  110.  
  111. vhlist(_) = vnull();
  112. vhlist(sep, head) = head | sep;
  113. vhlist(sep, head, ...) = (head | sep) & vhlist(sep, ...);
  114.  
  115. vtlist(_) = vnull();
  116. vtlist(sep, head) = head | sep;
  117. vtlist(sep, head, ...) = (head | sep) ~ vtlist(sep, ...);
  118.  
  119. commalist(...)     = tlist(", ", ...);
  120. semicolonlist(...) = tlist("; ", ...);
  121.  
  122. // Make size even
  123. heven(box, align) = box ^ hspace(box + box % align);
  124. veven(box, align) = box ^ vspace(box + box % align);
  125. even(box, align) = heven(veven(box, align), align);
  126. heven(box) = heven(box, 2);
  127. veven(box) = veven(box, 2);
  128. even(box) = heven(veven(box));
  129.  
  130. // Conversions
  131. // Convert digit
  132. num(a);
  133. digit(0) = "0";
  134. digit(1) = "1";
  135. digit(2) = "2";
  136. digit(3) = "3";
  137. digit(4) = "4";
  138. digit(5) = "5";
  139. digit(6) = "6";
  140. digit(7) = "7";
  141. digit(8) = "8";
  142. digit(9) = "9";
  143. digit(10) = "a";
  144. digit(11) = "b";
  145. digit(12) = "c";
  146. digit(13) = "d";
  147. digit(14) = "e";
  148. digit(15) = "f";
  149. digit(_) = fail("ungueltiger parameter");
  150.  
  151. // Convert numbers
  152. // Natural numbers
  153. pnum(a, base) =
  154.   if a < base then
  155.     digit(a) 
  156.   else 
  157.     pnum(a / base, base) & pnum(a % base, base)
  158.   fi;
  159.  
  160. // Entire numbers
  161. num(a, base) =
  162.   if a < 0 then "-" & pnum(0 - a, base) else pnum(a, base) fi;
  163. num(a) = num(a, 10);
  164.  
  165. // Bases
  166. dec(a) = num(a, 10);
  167. oct(a) = num(a, 8);
  168. bin(a) = num(a, 2);
  169. hex(a) = num(a, 16);
  170.  
  171. // Lines with some space at the inner side
  172. n_rule() = hrule() | hwhite();
  173. w_rule() = vrule() & vwhite();
  174. s_rule() = hwhite() | hrule();
  175. e_rule() = vwhite() & vrule();
  176.  
  177. // Frames
  178. whiteframe(box, thickness) = 
  179.   hwhite(thickness) 
  180. | vwhite(thickness) & box & vwhite(thickness) 
  181. | hwhite(thickness);
  182. whiteframe(box) = whiteframe(box, whitethickness());
  183.  
  184. ruleframe(box, thickness) = 
  185.   hrule(thickness) 
  186. | vrule(thickness) & box & vrule(thickness) 
  187. | hrule(thickness);
  188. ruleframe(box) = ruleframe(box, rulethickness());
  189.  
  190. frame(box)       = ruleframe(whiteframe(box));
  191. doubleframe(box) = frame(frame(box));
  192. thickframe(box)  = ruleframe(frame(box));
  193.  
  194. // Centering
  195. hcenter(box)  = fill() & box & fill();
  196. vcenter(box)  = fill() | box | fill();
  197. center(box)   = hcenter(vcenter(box));
  198.  
  199. // Flushing
  200. n_flush(box) = hcenter(box) | fill();
  201. s_flush(box) = fill() | hcenter(box);
  202. w_flush(box) = vcenter(box) & fill();
  203. e_flush(box) = fill() & vcenter(box);
  204. sw_flush(box) = fill() | (box & fill());
  205. nw_flush(box) = (box & fill()) | fill();
  206. se_flush(box) = fill() | (fill() & box);
  207. ne_flush(box) = (fill() & box) | fill();
  208.  
  209. // Indentation
  210. indent(box) = indentamount() & box;
  211.  
  212. // Underlines, Overlines, Crosslines
  213. underline(box) = box | hrule();
  214. overline(box)  = hrule() | box;
  215. crossline(box) = hfix(box ^ vcenter(hrule()));
  216.  
  217. // Poor Man's Bold
  218. doublestrike(box) = box ^ (hspace(1) & box);
  219.  
  220. // Abbreviations
  221. dquote() = "\"";
  222. squote() = "'";
  223. copyright() = "(c)";
  224.